import React, { useState } from 'react'
import style from './index.module.scss'
import { useSearchParams } from 'react-router-dom'
import CardList from '../Common/CardList'
import UserList from './UserList'
const titleList = [
    {title:"图文",key:1},
    {title:"用户",key:2}
]
export default function SearchList() {
    const [activeKey,setActiveKey]=useState(1)
    const [searchParams] = useSearchParams()
    const searchKey = searchParams.get('key')
  return (
    <div className={style.SearchList}>
      <div className='SearchTitle'>
        {titleList.map(item=><div className={item.key===activeKey?`active`:''} onClick={()=>{setActiveKey(item.key);console.log(item.key);
        }} key={item.key}>{item.title}</div>)}
      </div>
      {activeKey===1&&<CardList params={{searchKey}} comefrom='search'/>}
      {activeKey===2&&<UserList searchKey={searchKey}/>}
    </div>  
  )
}
